<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <h1>产品结构查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目编号
                                    </label>
                                    <label class="control-label">
                                        <input name="proCode" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目名称
                                    </label>
                                    <label class="control-label">
                                        <input name="proName" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        需方
                                    </label>
                                    <label class="control-label">
                                        <input name="customer" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入需方"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        安装地点
                                    </label>
                                    <label class="control-label">
                                        <input name="insSite" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入安装地点"/>
                                    </label>
                                </div>
<!--                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">-->
<!--                                    <label class="control-label">-->
<!--                                        已创建专业：-->
<!--                                    </label>-->
<!--                                    <label class="control-label">-->
<!--                                        <select id="selectSpecials" style="width: 197px" class="form-group selectpicker" data-actions-box="true" multiple>-->
<!--                                            <option selected="selected"-->
<!--                                                    th:each="item:${specialList}" th:value="${item.specialId}"-->
<!--                                                    th:text="${item.special}"></option>-->
<!--                                        </select>-->
<!--                                        <input name="haveSpecials" th:value="${specialIds}" type="hidden" style="display: none" />-->
<!--                                    </label>-->
<!--                                </div>-->
                                <button id="btn-search" type="button" class="btn btn-success">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div id="toolbar" class="row">
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table, tempTable, tempData = new Array(), currentProject;
    $(function () {
        // $("#selectSpecials").change(function (){
        //     let ids =  $("#selectSpecials").val();
        //     let idsStr = '';
        //     for (let i = 0; i < ids.length; i++) {
        //         idsStr+=ids[i]+',';
        //     }
        //     idsStr=idsStr.substring(0,idsStr.length-1);
        //    $("#queryForm [name='haveSpecials']") .val(idsStr);
        // });
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "proStrucEdit/proList",
            showColumns: true,
            showExport: true,
            columns: [
                {
                    title: '序号', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: '项目编号', field: 'proCode',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目名称', field: 'proName',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目数量', field: 'proQty',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '需方', field: 'customer',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '安装地点', field: 'insSite',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '已创建专业', field: "haveSpecials", width: '200',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '操作', width: '60',
                    formatter: function (value, row, index) {
                        let elements = new Array();
                        if (hasP('pro:proStrucEdit:edit')) {
                            elements.push('<button class="btn btn-info btn-xs" onclick="edit(' + row.proId + ')">查看</button>');
                        }
                        return elements.join('');
                    }
                }
            ]
        });
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

    });

    /**
     * 跳转到编辑产品结构
     */
    function edit(proId) {

        window.open(ctx + 'proStrucEdit/gotoEdit/' + proId);
    }
    /**
     * 重新加载
     */
    function reLoad() {
        js.table.refresh(table);
    }
</script>
</body>
</html>